# Copyright © 2012, 2013 dr. ir. Jeroen M. Valk
# 
# This file is part of ComPosiX.
# 
# ComPosiX is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
# 
# ComPosiX is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along with
# ComPosiX. If not, see <http://www.gnu.org/licenses/>.

PREFIX=/usr/local/composix
WWW=/var/www
CGIBIN=/usr/lib/cgi-bin

CC=gcc
CFLAGS=-Wall -std=c99

all: target/bin/composix js setl sh

target:
	mkdir target

target/bin: target
	mkdir target/bin

target/www: target
	mkdir target/www

target/cgi-bin: target
	mkdir target/cgi-bin

target/bin/composix: src/main/c/composix.c target/bin
	$(CC) $(CFLAGS) $< -o $@

js: target/www
	cp src/main/javascript/*.js target/www

setl: target/bin target/cgi-bin
	cp src/main/setl/*.setl target/bin
	cp src/main/setl/cgi/*.setl target/cgi-bin

sh: target/bin
	cp src/main/sh/*.sh target/bin

install: target/bin/composix
	mkdir -p $(PREFIX)/bin
	cp target/www/* $(WWW)/
	cp target/bin/* $(PREFIX)/bin/
	cp --preserve=mode target/cgi-bin/* $(CGIBIN)/

rinstall:
	scp target/www/* jeroen@server:$(WWW)/
	scp target/bin/* jeroen@server:$(PREFIX)/bin/
	scp --preserve=mode target/cgi-bin/* jeroen@server:$(CGIBIN)/

clean:
	rm -rf target

